package org.peterbjornx.formats;

import org.peterbjornx.io.*;

import java.awt.*;
import java.io.IOException;

public class FileJagexImageReader extends AbstractJagexImageReader{

	private AbstractFileStore afs = null;

	public FileJagexImageReader(AbstractFileStore a)
	{
		afs = a;
	}
	
	public Image getImage(String name, int id) throws IOException {
		return AbstractJagexImageReader.getImage(id,afs.getFile(name+".DAT"),afs.getFile("INDEX.DAT"));
	}

    public Image getImageJPG(String name,Component c) throws IOException {
        byte[] data = afs.getData(name+".DAT");
        Image image = Toolkit.getDefaultToolkit().createImage(data);
        MediaTracker mediatracker = new MediaTracker(c);
        mediatracker.addImage(image, 0);
        try {
            mediatracker.waitForAll();
        } catch (InterruptedException e) {
            //Empty
        }
        return image;
    }

}